﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Phidgets;
using Phidgets.Events;

namespace LorraineSec.Libraries.Sensors.Simulators
{
    public class PhidgetUSBRFID_Sim : RFID
    {
        public RFIDDigitalOutputCollection outputs;

        public new bool Antenna { get; set; }
        public new string LastTag { get; private set; }
        public new bool LED { get; set; }
        public new bool TagPresent { get; private set; }

        //public event AttachEventHandler Attach;
        //public event DetachEventHandler Detach;
        //public event ErrorEventHandler Error;

        public new event OutputChangeEventHandler OutputChange;
        public new event TagEventHandler Tag;
        public new event TagEventHandler TagLost;

        private string currentTag;

        public PhidgetUSBRFID_Sim()
        {
            Antenna = true;
            LastTag = null;
            LED = false;
            TagPresent = false;

            currentTag = null;
        }

        public void simulateAttach()
        {

        }

        public void simuateDetach()
        {

        }

        public void simulateTag(bool isPresent, string tagID)
        {
            TagPresent = isPresent;
            currentTag = tagID;
            LastTag = tagID;

            _TagEventArgs t = (_TagEventArgs)TagEventArgs.Empty;
            t.Tag = tagID;

            Tag(this, (TagEventArgs)(object)t);
        }


        public class _TagEventArgs
        {
            public string Tag { get; set; }

            public static implicit operator _TagEventArgs(TagEventArgs a)
            {
                return a;
            }
        }
    }


}
